/*******************************************************************************
*  file    : webviewwidget.cpp
*  created : 07.05.2013
*  author  : 
*******************************************************************************/

#include "webviewwidget.hpp"
#include <QWebView>
#include <QBoxLayout>
#include <qlogger.hpp>

namespace {
QLogger* l_ = QLoggerEngine::getLogger("web");
}

WebViewWidget::WebViewWidget(QWidget *parent) :
    QWidget(parent)
{
    QHBoxLayout * lay = new QHBoxLayout;
    web_view_ = new QWebView(this);
    lay->addWidget(web_view_);

    this->setLayout(lay);
}

void WebViewWidget::navigate(const QUrl& url)
{
    web_view_->load(url);
}

void WebViewWidget::finishLoading(bool b)
{
    QString loadres;
    if(b)
        loadres = "OK";
    else
        loadres = "Fail";
    logInfo(l_) << "Page load" << loadres;
}

void WebViewWidget::createActions()
{
    //connect(page_, SIGNAL(loadFinished(bool)), this, SLOT(onPageLoaded(bool)) );
    //connect(page_, SIGNAL(loadStarted())     , this, SLOT(onLoadStart()) );
    //connect(page_, SIGNAL(loadProgress(int)) , this, SLOT(onProgress(int)) );
}
